package com.nineclock.system.controller;

import com.nineclock.common.entity.Result;
import com.nineclock.system.service.SmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//发送短信控制器
@RestController
@RequestMapping("sms")
@Api(value = "发送短信接口", tags = "系统服务")
public class SmsController {

    @Autowired(required = false)
    private SmsService smsService;

    //短信: 发送短信验证码创
    //接口路径：GET/sys/sms/code
    @ApiOperation(value = "短信: 发送短信验证码")
    @GetMapping("/code")
    public Result sendSms(String mobile,String type){
        smsService.sendSms(mobile,type);
        return Result.success();
    }

    //短信: 验证码校验
    //接口路径：GET/sys/sms/verify
    @ApiOperation(value = "短信: 验证码校验")
    @GetMapping("verify")
    public  Result<Boolean> verifySmsCode(String mobile, String type, String checkcode){
        boolean verifyResult = smsService.verifySmsCode(mobile,type,checkcode);
        return Result.success(verifyResult);
    }

}
